getViewLifecycleOwner
Get a LifecycleOwner that represents the Fragment's View lifecycle. In most cases, this mirrors the lifecycle of the Fragment itself, but in cases of detached Fragments, the lifecycle of the Fragment can be considerably longer than the lifecycle of the View itself.
Namely, the lifecycle of the Fragment's View is:
- created after onViewStateRestored
- started after onStart
- resumed after onResume
- paused before onPause
- stopped before onStop
- destroyed before onDestroyView
The view lifecycle remains valid through the call to onDestroyView, after which getView will return null, the view lifecycle will be destroyed, and this method will throw an IllegalStateException. Consider using getViewLifecycleOwnerLiveData or runOnCommit to receive a callback for when the Fragment's view lifecycle is available.
This should only be called on the main thread.
Overriding this method is no longer supported and this method will be made final
in a future version of Fragment.
Return
A LifecycleOwner that represents the Fragment's View lifecycle.